import { ref } from 'vue';
import { defineStore } from 'pinia';

// 定义一个简单的存储模块
export const useCacheStore = defineStore('cache', () => {
  const cacheData = ref(new Map<string, any>());

  const getCache = (key: string) => {
    return cacheData.value.get(key);
  };
  // 设置缓存数据
  const setCache = (key: string, data: any) => {
    cacheData.value.set(key, data);
  };
  // 清除缓存数据
  const clearCache = (key: string) => {
    cacheData.value.delete(key);
  };
  // 清除所有缓存数据
  const clearAllCache = () => {
    cacheData.value.clear();
  };

  return { cacheData, getCache, setCache, clearCache, clearAllCache };
});
